<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function jc() {
		var n=1;
		var input=document.getElementById("input").value;
		var span=document.getElementById("result");
		if(isNaN(input)){
			span.innerHTML="不是数字!";
		}else if(input<0){
			span.innerHTML="小于0的数字没有阶乘!";
		}else if(input==0){
			span.innerHTML=1;
		}else{
			console.log(parseInt(input));
			for(var i=2;i<=parseInt(input);i++){
				n=i*n;
			}
			span.innerHTML=n;
		}
	}
</script>
</head>
<body>
	<p>
		<input type="text" id="input"/>
		<input type="button" value="阶乘" onclick="jc();"/> =
	</p>
	<p><textarea rows="10" cols="10" id="result"></textarea></p>
</body>
</html>